<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <link rel="icon" href="img/bigtree.png" type="image/x-icon">
    <link rel="shortcut icon" href="img/bigtree.png" type="image/x-icon">
    <title>会飞的鱼</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }
        
        body {
            margin: 0 10px;
            overflow: hidden;
        }
        
        ul,
        ol {
            list-style: none;
        }
        
        a {
            text-decoration: none;
            color: inherit;
        }
        
        .result {
            padding: 20px;
            border: 1px solid #d2d2d2;
            border-radius: 5px;
        }
        
        input {
            width: 185px;
            height: 40px;
            line-height: 40px;
            padding-left: 15px;
            border: 1px solid #000;
            border-radius: 5px;
            outline: none;
        }
        
        button {
            width: 100px;
            height: 40px;
            line-height: 40px;
            font-size: 26px;
            text-align: center;
            border: 1px solid #2dced2;
            border-radius: 5px;
            outline: none;
            cursor: pointer;
        }
        
        .loinBox,
        .registerBox {
            width: 100%;
            border: 1px dashed #d2d2d2;
            margin-top: 20px;
        }
        
        li {
            text-align: center;
            margin-bottom: 10px;
        }
        
        #getCode {
            font-size: 16px;
        }
        
        .footer {
            width: 100%;
            height: 30px;
            line-height: 30px;
            text-align: center;
            background: #acf6ef;
        }
    </style>
</head>

<body>
    <div class="result">等待结果...</div>
    <div class="loinBox">
        <ul>
            <li>账号：<input type="text" placeholder="请输入您的登录账号" id="loginName"></li>
            <li>密码：<input type="text" placeholder="请输入您的登录密码" id="loginPassword"></li>
            <li><button id="loginBtn">登录</button></li>
        </ul>
    </div>
    <div class="registerBox">
        <ul>
            <li>账号：<input type="text" placeholder="请输入您的登录账号" id="registerName"></li>
            <li>密码：<input type="text" placeholder="请输入您的登录密码" id="registerPassword"></li>
            <li>确认：<input type="text" placeholder="请再次输入您的登录密码" id="conPassword"></li>
            <li>邮箱：<input type="text" placeholder="请输入您的邮箱" id="email"></li>
            <li>验证：<input type="text" placeholder="请输入您的验证码" id="verCode"></li>
            <li><button id="getCode">获取验证码</button></li>
            <li><button id="registerBtn">注册</button></li>
        </ul>
    </div>
    <div class="footer">
        <a href="http://beian.miit.gov.cn/" target="_blank">粤ICP备2020119735号</a>
    </div>
    <script src="https://s3.pstatp.com/cdn/expire-1-M/jquery/3.3.1/jquery.min.js"></script>
    <script>
        /* 登录 */
        $("#loginBtn").on("click", function() {
            let $loginName = $("#loginName").val();
            let $loginPassword = $("#loginPassword").val();
            $.post("/user/login", {
                loginName: $loginName,
                loginPassword: $loginPassword
            }, function(res) {
                console.log("log", res);
                $(".result").text(JSON.stringify(res));
            });
        });
        /* 获取注册验证码 */
        $("#getCode").on("click", function() {
            let $email = $("#email").val();
            $.get("/user/getCode", {
                email: $email,
            }, function(res) {
                console.log("reg", res);
                $(".result").text(JSON.stringify(res));
            });
        });
        /* 注册 */
        $("#registerBtn").on("click", function() {
            let $registerName = $("#registerName").val();
            let $registerPassword = $("#registerPassword").val();
            let $email = $("#email").val();
            let $verCode = $("#verCode").val();
            console.log("555", $registerName, $registerPassword, $email, $verCode);
            $.post("/user/register", {
                registerName: $registerName,
                registerPassword: $registerPassword,
                email: $email,
                verCode: $verCode
            }, function(res) {
                console.log("reg", res);
                $(".result").text(JSON.stringify(res));
            });
        });
    </script>
</body>

</html>